//
//  ViewController.m
//  tomcat
//
//  Created by student on 16/2/19.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)knockout:(UIButton *)sender
{
    
    int imageamount = 0;
    NSString *title;
    switch (sender.tag)
    {
        case 0:
            imageamount = 80;
            title = @"knockout";
            break;
        case 1:
            imageamount = 25;
            title = @"angry";
            break;
        case 2:
            imageamount = 33;
            title = @"stomach";
            break;
        case 3:
            imageamount = 29;
            title = @"footRight";
            break;
        case 4:
            imageamount = 29;
            title = @"footLeft";
            break;
        case 5:
            imageamount = 12;
            title = @"cymbal";
            break;
        case 6:
            imageamount = 80;
            title = @"drink";
            break;
        case 7:
            imageamount = 39;
            title = @"eat";
            break;
        case 8:
            imageamount = 27;
            title = @"fart";
            break;
        case 9:
            imageamount = 23;
            title = @"pie";
            break;
        case 10:
            imageamount = 55;
            title = @"scratch";
            break;
            
        default:
            break;
    }

    NSMutableArray *marr = [[NSMutableArray alloc]init];
    for (int i = 0; i<10; i++)
    {
        NSString *picname = [NSString stringWithFormat:@"%@_0%i.jpg",title,i];
        UIImage *image = [UIImage imageNamed:picname];
        [marr addObject:image];
    }
    for (int i = 10; i<=imageamount; i++)
    {
        NSString *picname = [NSString stringWithFormat:@"%@_%i.jpg",title,i];
        UIImage *image = [UIImage imageNamed:picname];
        [marr addObject:image];
    }
    
    self.imageview.animationImages=marr;
    self.imageview.animationDuration = imageamount/10;
    self.imageview.animationRepeatCount = 1;
    [self.imageview startAnimating];
    
}


@end
